package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotRoomClean;
import com.gaohe.hotal.service.IHotRoomCleanService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 房间清洁Controller
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/hotal/clean")
public class HotRoomCleanController extends BaseController
{
    @Autowired
    private IHotRoomCleanService hotRoomCleanService;

    /**
     * 查询房间清洁列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:clean:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotRoomClean hotRoomClean)
    {
        startPage();
        List<HotRoomClean> list = hotRoomCleanService.selectHotRoomCleanList(hotRoomClean);
        return getDataTable(list);
    }

    /**
     * 导出房间清洁列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:clean:export')")
    @Log(title = "房间清洁", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotRoomClean hotRoomClean)
    {
        List<HotRoomClean> list = hotRoomCleanService.selectHotRoomCleanList(hotRoomClean);
        ExcelUtil<HotRoomClean> util = new ExcelUtil<HotRoomClean>(HotRoomClean.class);
        util.exportExcel(response, list, "房间清洁数据");
    }

    /**
     * 获取房间清洁详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:clean:query')")
    @GetMapping(value = "/{cleanId}")
    public AjaxResult getInfo(@PathVariable("cleanId") Long cleanId)
    {
        return success(hotRoomCleanService.selectHotRoomCleanByCleanId(cleanId));
    }

    /**
     * 新增房间清洁
     */
    @PreAuthorize("@ss.hasPermi('hotal:clean:add')")
    @Log(title = "房间清洁", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotRoomClean hotRoomClean)
    {
        return toAjax(hotRoomCleanService.insertHotRoomClean(hotRoomClean));
    }

    /**
     * 修改房间清洁
     */
    @PreAuthorize("@ss.hasPermi('hotal:clean:edit')")
    @Log(title = "房间清洁", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotRoomClean hotRoomClean)
    {
        return toAjax(hotRoomCleanService.updateHotRoomClean(hotRoomClean));
    }

    /**
     * 删除房间清洁
     */
    @PreAuthorize("@ss.hasPermi('hotal:clean:remove')")
    @Log(title = "房间清洁", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cleanIds}")
    public AjaxResult remove(@PathVariable Long[] cleanIds)
    {
        return toAjax(hotRoomCleanService.deleteHotRoomCleanByCleanIds(cleanIds));
    }
}
